var $;
layui.use(['table','jquery'],function () {
    $ = layui.jquery;
    var table = layui.table;

    /*获取日志信息*/
    getGoodsLog();
    function getGoodsLog(){
        var id=localStorage.getItem('productRecId');
        $.ajax({
            url:'/goodsTable/getGoodsJournal',
            type:'post',
            dataType:'json',
            data:{'productId':id,"type":3},
            success:function (data) {
                tablereload(data.data);
            }
        });
    }
    function tablereload(data) {
        table.render({
            elem: '#table',
            data: data,
            title: '数据列表',
            limit: 10,
            toolbar: '#toptool',
            page: {
                layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
                first: "首页",
                last: "尾页",
            },
            size: 'lg',
            cols: [[//定义列
                {type: 'checkbox'},//复选框靠左
                {field: 'courseId', title: '商品编号', align: 'center'},
                {field: "courseName", title: "商品名称", align: 'center'},
                {field: '', title: "商品名称", align: 'center',
                    templet: function (data) {
                        var p="<p>原价："+data.coursePrice+"元</p><p>现价："+data.courseNprice+"元</p>"
                        return p;
                    }
                },
                {
                    field: 'courseStatus',
                    title: "上架/下架",
                    align: 'center',
                    templet: function (data) {
                        if(data.courseStatus==2){
                            var radio = '<a href="javascript:updateStatus('+data.id+","+data.courseStatus+');">上架中</a>'
                        }else if(data.courseStatus==3){
                            var radio = '<a href="javascript:updateStatus('+data.id+","+data.courseStatus+');">未上架</a>'
                        }else{
                            var radio = "其他";
                        }
                        return radio;
                    }
                },
                {field: '', title: "审核状态", align: 'center',
                    templet: function (data) {
                        if(data.courseCstatus==2){
                            var radio = '<p>审核通过</p>'
                        }else if(data.courseCstatus==3){
                            var radio = '<p>审核通过</p>'
                        }else if(data.courseCstatus==4){
                            var radio = '<p>审核中</p>'
                        }else if(data.courseCstatus==5){
                            var radio = '<p>审核失败</p>'
                        }else{
                            var radio = '<p>未知</p>'
                        }
                        return radio;
                    }
                },
                {field: '', title: "商品分类", align: 'center',
                    templet: function (data) {
                        var user="<p>"+data.userName+"</p><p>"+data.updateDate+"</p>"
                        return user;
                    }
                },
            ]],
        });
    }
})




